package com.jsong.linuo.object;

import java.util.ArrayList;

/**
 * @Author: 黎诺
 * @CreateTime: 2025-04-29
 * @Description: equals
 */

public class Test02 {
    public static void main(String[] args) {
        Person p1 = new Person("小西", 22);
        Person p2 = new Person("小西", 22);
        //比较的是地址值
        System.out.println(p1 == p2);
        System.out.println(p1.equals(p2));

        System.out.println("=================");
        //传的对象不是Person
        ArrayList<Object> list = new ArrayList<>();
        System.out.println(p1.equals(list));

        System.out.println("=================");
        //传空值
        System.out.println(p1.equals(null));

        System.out.println("=================");
        //传自己
        System.out.println(p1.equals(p1));

        System.out.println("=================");

        String s1 = new String("hello");
        String s2 = new String("hello");
        //重写过equals()方法
        System.out.println(s1.equals(s2));


    }
}
